import { BaseModel } from './BaseModel.js';
import { dataFiles } from '../config/database.js';

const defaultStudents = [
  {
    id: 1,
    name: '张三',
    studentId: '20240001',
    gender: '男',
    birthDate: '2000-01-15',
    idCard: '110101200001015432',
    marketingDepartment: '市场一部',
    className: '计算机科学与技术1班',
    college: '计算机学院',
    phone: '13800138001',
    dormBuilding: '紫荆1号楼',
    dormRoom: '101',
    status: 'active',
    enrollmentDate: '2022-09-01',
    email: '',
    guardianName: '',
    guardianPhone: '',
    guardianRelationship: '',
    grade: '',
    major: '',
    department: ''
  },
  {
    id: 2,
    name: '李四',
    studentId: '20240002',
    gender: '女',
    birthDate: '2001-03-20',
    idCard: '110101200103205678',
    marketingDepartment: '市场二部',
    className: '软件工程2班',
    college: '软件学院',
    phone: '13800138002',
    dormBuilding: '银杏2号楼',
    dormRoom: '201',
    status: 'active',
    enrollmentDate: '2023-09-01',
    email: '',
    guardianName: '',
    guardianPhone: '',
    guardianRelationship: '',
    grade: '',
    major: '',
    department: ''
  }
];

export class Student extends BaseModel {
  constructor() {
    super(dataFiles.students, defaultStudents);
  }

  findByStudentId(studentId) {
    return this.findOne({ studentId });
  }

  findByClass(className) {
    const data = this.findAll();
    return data.filter(student => student.className === className);
  }

  findByMarketingDepartment(department) {
    const data = this.findAll();
    return data.filter(student => student.marketingDepartment === department);
  }
}